# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=7

inherit cmake-utils git-r3

DESCRIPTION="Obs studio output plugin for Video4Linux2 devices."
HOMEPAGE="https://github.com/CatxFish/obs-v4l2sink"
MY_AUTHOR="CatxFish"
EGIT_REPO_URI="https://github.com/CatxFish/obs-v4l2sink.git"

if [[ ${PV} == "9999" ]] ; then
	EGIT_BRANCH="master"
	KEYWORDS=""
else
	EGIT_COMMIT="${PV}"
	KEYWORDS="~x86 ~amd64"
fi

LICENSE="GPL-2"
SLOT="0"

src_prepare(){
	default
	sed -i 's=include(${LIBOBS_INCLUDE_DIR}/../cmake/external/ObsPluginHelpers.cmake)=include('"${FILESDIR}"'/ObsPluginHelpers.cmake)=g' "${S}"/external/FindLibObs.cmake || die 'Failed to patch ObsPluginHelpers.camke include location.'
	cp -f "${FILESDIR}"/CMakeLists.txt "${S}"/CMakeLists.txt || die "Failed to patch obs-frontend-api include location."
	sed -i 's@EBUILDFILESDIR@'"${FILESDIR}"'@g' "${S}"/CMakeLists.txt || die "Failed to patch obs-frontend-api include location."
	sed -i 's@/lib/@/'"$(get_libdir)"'/@g' "${S}"/CMakeLists.txt || die "Failed to patch to add correct libdir."
	cmake-utils_src_prepare
}

src_configure() {
	mycmakeargs=( -DLIBOBS_INCLUDE_DIR="${EPREFIX}"/usr/include/obs/ )
	cmake-utils_src_configure
}
